/*
 * Application.java
 *
 */

package net.kernub.webcore.client;

import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.ImageBundle;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

import net.kernub.webcore.client.Header;

public class Application extends Composite
{
	private class Image extends ImageBundle
	{
		@Resource( "logo.png" )
		public AbstractImagePrototype logo();
	};

	private Image image = GWT.create( Image.class );

	private Tree menuTree = null;
	private DecoratorPanel contentPanel;
	private SimplePanel contentWrapper;

	public Application()
	{
		
		initWidget( createApplication() );

		// Give the overall composite a style name
		//setStyleName( "application" );
	}

	public Tree getMenuTree()
	{
		return this.menuTree;
	}

	private Widget createApplication()
	{
		final HorizontalPanel mainPanel = new HorizontalPanel();
		mainPanel.setWidth( "100%" );
		mainPanel.add( createLeftPanel() );
		mainPanel.add( createRightPanel() );

		return mainPanel;
	}

	private Widget createLeftPanel()
	{
		final VerticalPanel panel = new VerticalPanel();
		panel.add( image.logo().creaetImage() );
		panel.add( this.menuTree );

		return panel;
	}

	private Widget createRightPanel()
	{
		final VerticalPanel panel = new VerticalPanel();
		final Header header = new Header();

		contentPanel.add( contentWrapper );

		panel.setWidth( "100%" );
		panel.add( header );
		panel.add( contentPanel );

		return panel;
	}
	
	public void setContentWidget( ContentWidget cw )
	{
		contentWrapper.setWidget( cw );
	}

};

